package com.zhiche.lisa.bms.dao.mapper.fee;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.zhiche.lisa.bms.dao.model.fee.FeePayable;
import com.zhiche.lisa.bms.pojo.vo.fee.FeePayableHeaderVO;
import com.zhiche.lisa.bms.pojo.vo.fee.FeePayablePermissVO;
import com.zhiche.lisa.bms.pojo.vo.fee.FeePayableVO;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 应付账款 Mapper 接口
 * </p>
 *
 * @author zhangkun
 * @since 2018-09-03
 */
public interface FeePayableMapper extends BaseMapper<FeePayable> {

    /**
     * 根据id查询应付账款
     *
     * @param ew
     * @return
     */
    FeePayableHeaderVO selectSumFeePayable(@Param("ew") Wrapper<FeePayable> ew);

    /**
     * 无token查询账款
     *
     * @param ew
     * @return
     */
    List<FeePayable> selectListNoTenant(@Param("ew") Wrapper<FeePayable> ew);

    List<FeePayableVO> selectPayableAndPriceDtlListNoTenant(@Param("ew") Wrapper<FeePayable> ew);

    /**
     * 无token查询账款集合
     *
     * @param page
     * @param ew
     * @return
     */
    List<FeePayable> selectPageNoTenant(Page<FeePayable> page, @Param("ew") Wrapper<FeePayable> ew);

    /**
     * 根据账款id获取对应的账款
     *
     * @param billId
     * @return
     */
    BigDecimal getFeePayableDeductTotalByBillid(@Param("billId") Long billId);

    /**
     * 根据id获取对应的指令是否全部回单
     *
     * @param idList
     * @return
     */
    List<FeePayablePermissVO> queryFeePayblePermiss(@Param("idList") List<Long> idList);

    /**
     * 计算总油费和总现金
     *
     * @param orderCode
     * @return
     */
    List<FeePayable> selectCashAndOilSumNoTenant(@Param("orderCode") String orderCode);

    /**
     * 如果正常发运, 更新慧运车未发运的数据
     *
     * @param orderCode
     */
    void updateHuiyuncheLoadStatusByOrderCode(@Param("orderCode") String orderCode);

}
